package com.fzy.common.file;

import com.fzy.common.file.pdf.PDFUtil;
import com.fzy.common.file.pdf.component.PDFHeaderFooter;

import java.util.ArrayList;
import java.util.List;

/**
 * 测试
 */
public class ReportKit360 {

	public String createPDF(Object data, String fileName) {
		//pdf保存路径
		try {
			//设置自定义PDF页眉页脚工具类
			PDFUtil kit = new PDFUtil();
			PDFHeaderFooter headerFooter = new PDFHeaderFooter();
			kit.setHeaderFooterBuilder(headerFooter);
			//设置输出路径
			kit.setSaveFilePath("E:/你好.pdf");
			String saveFilePath = kit.exportToFile(fileName, data);
			return saveFilePath;
		} catch (Exception e) {
			e.printStackTrace();
			//log.error("PDF生成失败{}", ExceptionUtils.getFullStackTrace(e));
			return null;
		}

	}

	public static void main(String[] args) {

		ReportKit360 kit = new ReportKit360();
		TemplateBO templateBO = new TemplateBO();
		templateBO.setTemplateName("Hello iText! Hello freemarker! Hello jFreeChart!");
		templateBO.setFreeMarkerUrl("http://www.zheng-hang.com/chm/freemarker2_3_24/ref_directive_if.html");
		templateBO.setITEXTUrl("http://developers.itextpdf.com/examples-itext5");
		templateBO.setJFreeChartUrl("http://www.yiibai.com/jfreechart/jfreechart_referenced_apis.html");
		templateBO.setImageUrl(
				"https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png");
		templateBO.setPicUrl(
				"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1494219643845&di=0c10a6ccc6ef3099d5c43e581ffcd31e&imgtype=0&src=http%3A%2F%2Fwww.ysg88.com%2FUploadFiles%2FFCK%2F2014-08%2F201408110V06J8L4J4.jpg");
		List<String> scores = new ArrayList<String>();
		scores.add("90");
		scores.add("95");
		scores.add("98");
		templateBO.setScores(scores);
		String path = kit.createPDF(templateBO, "hello.ftl");
		System.out.println(path);

	}

}
